<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图表</title>
    <script type="text/javascript" src="../js/jquery-1.8.0.js"></script>
    <script src="../js/echarts.min.js"></script>
</head>
<body>
<div id="main" style="width: 100%; height: 200px;"></div>


<script type="text/javascript">
    var series = [];    //图表数据
    var xAxis = [];     //图表X坐标
    var xAxisData = [];    //定义图形X坐标数据集
    var seriesDate = [];
    var seriesAllDate = [];

    for (var i = 0; i < 3; i++) {
        var name = "测试" + i;
        xAxisData.push(name);  //给X坐标设定值
        var value1 = 0.2 + i;
        var value2 = 0.5 + i;

        var xvalue = i;

        if (value2 != "") {
            seriesDate = [];
            seriesDate.push({x: xvalue, y: parseFloat(value1)});
            var xvalue1 = xvalue + 0.001;
            seriesDate.push({x: xvalue1, y: parseFloat(value2)});
            series.push({name: name, lineWidth: 8, marker: {symbol: 'square'}, data: seriesDate});
        }
        seriesAllDate.push({y: parseFloat(value1)});
    }
    xAxis = xAxisData;
    // series.push({ name: "全部", marker: { enabled: false }, data: seriesAllDate });


    //条形图
    var myChart = echarts.init(document.getElementById('main'));
    option = {
        title: {
            text: '月份销量统计',
            subtext: '',
            x: 'center',
            top: 10,
            textStyle: {
                fontSize: 20
            }
        },
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c}'
        },
        xAxis: {
            name:'x值',
            type: 'category',
            data: xAxis
        },
        yAxis: {
            name:'t',
            type: 'value'
        },
        series: [{
            data: [1,2,3],
            type: 'line'
        }]
    };
    myChart.setOption(option);

</script>
</body>
</html>